//
//  ElectricityInfoViewController.m
//  EasyToo
//
//  Created by linshengqin on 13-9-18.
//
//

#import "ElectricityInfoViewController.h"
#import "ElectricFeeInfo.h"
@interface ElectricityInfoViewController ()

@end

@implementation ElectricityInfoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(id)initWithIndex:(int)Index
{
    self = [super init];
    if(self)
    {
        electricity_model = [ElectricityModel sharedata];
        info = [electricity_model.electricFeeInfoArray objectAtIndex:Index];

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    [self initMainView];
    [self initDetail];
}

-(void)initMainView
{
    _bgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [DeviceUtil getScreenWidth], [DeviceUtil getScreenHeight])];
    [self.view addSubview:_bgScrollView];
    _bgScrollView.contentSize = CGSizeMake(320, 700);
    _bgScrollView.showsVerticalScrollIndicator = YES;
    
}


-(void)initDetail
{
    UIImageView *imageView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 340)];
    imageView.image = [UIImage imageNamed: @"list2" ];
    //    UIImageView *imageView = [[UIImageView alloc] initWithImage:image] ;
    [_bgScrollView addSubview:imageView];
    
    //[self.view setBackgroundColor: [UIColor colorWithPatternImage: [UIImage imageNamed: @"qq_list"]]];
    // Do any additional setup after loading the view.
    UILabel *label_message = [[UILabel alloc] initWithFrame:CGRectMake(120, 0, 150, 30)];
    label_message.text = @"电费信息";
    label_message.textColor = [UIColor redColor];
    label_message.font = [UIFont systemFontOfSize:20];
    label_message.backgroundColor = [UIColor clearColor];
    [_bgScrollView addSubview:label_message];
    
    int i = 50;
    UILabel *label_account = [[UILabel alloc] initWithFrame:CGRectMake(30, i, 250, 20)];
    label_account.font = [UIFont systemFontOfSize:13];
    [label_account setText:[NSString stringWithFormat:@"用户编号 :%@",electricity_model.account]];
    [_bgScrollView addSubview:label_account];
    
    
    UILabel *label_price = [[UILabel alloc] initWithFrame:CGRectMake(30, i+30, 250, 20)];
    label_price.font = [UIFont systemFontOfSize:13];
    [label_price setText:[NSString stringWithFormat:@"用户名称 :%@",info.userName]];
    [_bgScrollView addSubview:label_price];
    
    UILabel *label_pay = [[UILabel alloc] initWithFrame:CGRectMake(30, i+60, 250, 20)];
    label_pay.font = [UIFont systemFontOfSize:13];
    [label_pay setText:[NSString stringWithFormat:@"帐单日期 :%@",info.billMonth]];
    //label_pay.text = @"支付方式:%@", self.payType;
    [_bgScrollView addSubview:label_pay];
    
    UILabel *label_pay1 = [[UILabel alloc] initWithFrame:CGRectMake(30, i+90, 250, 20)];
    label_pay1.font = [UIFont systemFontOfSize:13];
    float currentFee = [info.currentFee floatValue]/100;
    [label_pay1 setText:[NSString stringWithFormat:@"本金 :%.2f元",currentFee]];
    //label_pay.text = @"支付方式:%@", self.payType;
    [_bgScrollView addSubview:label_pay1];
    
    UILabel *label_pay2 = [[UILabel alloc] initWithFrame:CGRectMake(30, i+130, 250, 20)];
    label_pay2.font = [UIFont systemFontOfSize:13];
    float laterFee = [info.laterFee floatValue]/100;
    [label_pay2 setText:[NSString stringWithFormat:@"滞纳金 : %.2f元",laterFee]];
    //label_pay.text = @"支付方式:%@", self.payType;
    [_bgScrollView addSubview:label_pay2];
    
    UILabel *label_pay3 = [[UILabel alloc] initWithFrame:CGRectMake(30, i+160, 250, 20)];
    label_pay3.font = [UIFont systemFontOfSize:13];
    float consumption = [info.consumption floatValue]/100;

    [label_pay3 setText:[NSString stringWithFormat:@"用电量 : %.2f",consumption]];
    //label_pay.text = @"支付方式:%@", self.payType;
    [_bgScrollView addSubview:label_pay3];
    
    
    UILabel *label_total = [[UILabel alloc] initWithFrame:CGRectMake(150, i+250, 170, 20)];
    float totalFee = [info.totalFee floatValue]/100;

    [label_total setText:[NSString stringWithFormat:@"合计 :%.2f元",totalFee]];
    label_total.textColor = [UIColor redColor];
    label_total.font = [UIFont systemFontOfSize:18];
    label_total.backgroundColor = [UIColor clearColor];
    [_bgScrollView addSubview:label_total];
    
    UIButton *confirmButton = [[UIButton alloc] initWithFrame:CGRectMake(40, 340, 230, 40)];
    [confirmButton setBackgroundImage:[UIImage imageNamed:@"button_3"] forState:UIControlStateNormal];
    [confirmButton setTitle:@"返回" forState:UIControlStateNormal];
    [confirmButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    [_bgScrollView addSubview:confirmButton];
    
}
-(void)back:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
